1. Field of the Invention
The present invention relates generally to geometry accelerators in computer graphics and animation systems and, more particularly, to geometry accelerators that include a clipping machine that clips graphics primitives to one or more boundaries.
2. Related Art
Computer graphics systems are commonly used for displaying two- and three-dimensional graphical representations of objects on a two-dimensional video display screen. Current computer graphics systems provide highly detailed representations and are used in a variety of applications.
In a typical computer graphics system an object or model to be represented on the display screen is broken down into a plurality of graphics primitives. Primitives are basic components of a graphics display and may include, for example, points, lines, vectors, and polygons such as triangles and quadrilaterals. Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being represented on the display screen.
Generally, the primitives of the three-dimensional object to be rendered are defined by a host computer in terms of primitive data. For example, when the primitive is a triangle, the host computer may define the primitives in terms of the coordinates (X, Y, Z, and W) of its vertices, as well as the red, green and blue and alpha (R, G, B and .alpha.) color values of each vertex. Additional primitive data may be used in specific applications. Rendering hardware interpolates the primitive data to compute the display screen pixels that represent each primitive, and the R, G, and B color values for each pixel.
The basic components of a computer graphics system typically include a graphics interface and some specialized graphics system hardware. The graphics interface is typically provided to enable graphics applications located on the host computer to efficiently control the graphics system hardware. One of the more popular graphics interfaces is the OpenGL.RTM. standard, which provides an application program interface (API) to graphics system hardware. (OpenGL is a registered trademark of Silicon Graphics, Inc.).
The OpenGL software interface provides specific commands that are used to specify objects and operations to produce interactive, three-dimensional applications. OpenGL is a streamlined, hardware-independent interface designed to be implemented on many different hardware platforms. As such, in computer systems which support OpenGL, the operating systems and graphics application software programs can make calls to the computer graphics system according to the standardized API without knowledge of the underlying hardware configuration.
The OpenGL standard provides a complete library of low-level graphics manipulation commands for describing models of three-dimensional objects (the "GL" of OpenGL refers to "Graphics Library"). This standard was originally based on the proprietary standards of Silicon Graphics, Inc., but was later transformed into an open standard which is used in high-end graphics-intensive workstations, and, more recently, in high-end personal computers. The OpenGL standard is described in the OPENGL PROGRAMMING GUIDE, version 1.1 (1997), the OPENGL REFERENCE MANUAL, version 1.1 (1997), and a book by Segal and Akeley (of SGI) entitled THE OPENGL GRAPHICS SYSTEM: A SPECIFICATION (Version 1.0), all of which are hereby incorporated by reference in their entirety.
The graphics system hardware typically includes a geometry accelerator, a rasterizer, and a frame buffer. The graphics system may also include other hardware such as texture mapping hardware. The geometry accelerator receives primitive data from the host computer via the graphics interface. The primitive data defines the primitives that make up the model view to be displayed. The geometry accelerator performs transformations on the primitive data and may also perform such functions as lighting, clipping and plane equation calculations for each primitive. The output of the geometry accelerator, referred to as rendering data, is used by the rasterizer and the texture mapping hardware to generate final screen coordinate and color data for each pixel in each primitive. The pixel data from the rasterizer and the pixel data from the texture mapping hardware, if available, are combined and stored in the frame buffer for display on the video display screen.
One of the more complex operations that may be performed by a geometry accelerator is the clipping of graphics primitives. Clipping determines which portion of a graphics primitive is to be displayed in what is known as a "clip region." The clip region can be a two-dimensional area such as a window, or it can be a three-dimensional view volume. The primitives that are displayed in the clip region can be one-dimensional primitives (e.g., points or lines) or two-dimensional primitives (e.g., polygons).
The clipping of graphics primitives to a three-dimensional view volume is termed "view clipping". The three-dimensional view volume is defined by 6 orthogonal clipping planes, referred to herein as Xmax, Xmin, Ymax, Ymin, Zmax, Zmin. View clipping of primitives is required due to the finite size of the video display, but may also be required by downstream hardware rasterizers to prevent overflow of the rasterizer's internal counters. View clipping can also be used to increase performance of the graphics system, as further processing on primitives that lie outside the view volume need not be performed. In addition to performing view clipping, many graphics systems also perform "model clipping" of graphics primitives. Model clipping allows a user to specify one or more model clipping planes that may be used to further restrict the viewing volume or to remove portions of an object or model from view. Many graphics systems support 6 or more model clipping planes. By removing certain portions of the object or model from view, other areas of the model that were previously hidden from view can be visualized.
Although the clipping of graphics primitives may be performed within the geometry accelerator by means of a hardware-based clipping machine, it is conventionally implemented in software in the graphics system. One reason the clipping of graphics primitives has historically been performed in software rather than in hardware is that hardware implementations are generally more expensive, in terms of development time, cost, and risk, than software implementations, particularly given the rarity with which clipping operations have been performed. A further reason for performing clipping of graphics primitives in software rather than hardware is due to the amount of hardware that is needed to support clipping operations. For example, in conventional systems providing dedicated hardware within the geometry accelerator to perform clipping operations, two distinct clipping processors are provided. One clipping processor performs view clipping while the other performs model clipping. This dual-processor architecture is commonly used because view clipping and model clipping are conventionally required to be performed in different coordinate spaces.
For example, OpenGL specifies that view clipping and model clipping are performed in two different coordinate spaces. As shown diagrammatically in FIG. 1, OpenGL defines model clipping in "eye" coordinates 110 (eye space) and defines view clipping in "clip" coordinates 112 (clipping space). Graphics primitives (vertex data) and model clipping planes (m) are specified by the user in "object" coordinates 108 (object space), with model clipping planes being specified by the coefficients of the plane equation Ax+By+Cz+Dw=0. When a user specifies a model clipping plane, the model clipping plane (m) is transformed from object coordinates 108 to eye coordinates 110 by multiplying plane equation coefficients by the inverse transpose of the current modelview matrix (M.sup.-T). After a graphics primitive is assembled in object coordinates 108, the vertex data defining the primitive is transformed into eye coordinates 110 where model clipping is defined, by multiplying the vertex data by the current modelview matrix (M) 100. The model clipping planes are applied to the transformed vertex data to generate model clipped vertex data in eye coordinates 110. The model clipped vertex data is then transformed from eye coordinates 110 to clip coordinates 112 where view clipping is performed, by multiplying the model clipped vertex data by the current projection matrix (P) 102. After performing view clipping, the view and model clipped vertex data is transformed to "window" coordinates 116 (window space) by performing perspective division 104 and multiplying the view and model clipped vertex data by the current viewport (V) and device (D) matrices 106. Typically this is performed by multiplying the view and model clipped vertex data by a concatenation of the current viewport (V) and device (D) matrices. The vertex data defining the view and model clipped primitive in window coordinates can then be displayed. However, because OpenGL specifies that view clipping and model clipping are performed in two different coordinate spaces, performing view and model clipping in hardware within a geometry accelerator according to the manner specified by OpenGL conventionally requires two distinct clipping processors.
Because of the amount of vertex data transformation that is required to view and model clip a graphics primitive, some graphics systems depart from the literal terms of the OpenGL standard. More sophisticated graphics systems reduce the amount of vertex data that is transformed by performing model clipping in object coordinates 108 rather than in eye coordinates 110. As in OpenGL, when a user specifies a model clipping plane, the model clipping plane (m) is transformed from object coordinates 108 to eye coordinates 110 by multiplying plane equation coefficients by the inverse transpose of the current modelview matrix (M.sup.-T). After a graphics primitive is assembled in object coordinates 108, the model clipping plane is transformed back to object space 108 by multiplying the plane equation coefficients by the then current modelview matrix (M) 100. This step is performed because the modelview matrix used to transform the graphics primitive from object coordinates 108 to eye coordinates 110 may be different from the modelview matrix used to transform the model clip plane from object coordinates 108 to eye coordinates 110 (i.e., the current modelview matrix when the model clip plane was specified). The model clipping planes are applied to the vertex data in object space 108 to generate model clipped vertex data in object coordinates 108. The model clipped vertex data is then transformed from object coordinates 108 to clip coordinates 112 where view clipping is defined, by multiplying the model clipped vertex data by the current modelview matrix (M) 100 and the current projection matrix (P) 102. Conventionally this is performed by multiplying the model clipped vertex data by a concatenation of the current modelview matrix (M) 100 and the current projection matrix (P) 102 (MP). After performing view clipping in clip coordinates 112, the view and model clipped vertex data is transformed to window coordinates 116 by performing perspective division 104 and multiplying the view and model clipped vertex data and by a concatenation of the current viewport (V) and device (D) matrices 106 (VD). The vertex data defining the view and model clipped primitive in window coordinates 116 can then be displayed.
An advantage of this more sophisticated method is that model clipping planes, which are less frequently encountered than vertex data, are back transformed once, rather than having to forward transform all vertex data, some or all of which may be clipped away by the model clip planes. Thus, only the vertex data that remains after performing model clipping needs to be transformed, thereby increasing efficiency. However, because model clipping and view clipping are still performed in two different coordinate spaces, this more sophisticated method still requires two different clipping processors to perform both view and model clipping in hardware within the geometry accelerator.
However, as noted, the clipping of graphics primitives is only a subset of those functions that a geometry accelerator may perform. Frequently, clipping does not need to be performed at all. Moreover, the amount of surface area consumed by two distinct clipping processors within a geometry accelerator is quite large. Thus, performing view and model clipping within the geometry accelerator often requires sacrificing some other, more frequently performed operation, such as light enhancement, plane equation calculation, etc. Accordingly, for each of the foregoing reasons, the clipping of graphics primitives is conventionally performed in software by the graphics system, rather than in hardware within a geometry accelerator.